/***********************************************************************
 *
 * MODULE NAME:    stack_ent_api.h
 * PROJECT CODE:   Host Side Stack
 * DESCRIPTION:    Stack Entity API
 * MAINTAINER:     David Airlie
 * CREATION DATE:  1 May 2000
 *
 * SOURCE CONTROL: $Id: stack_ent_api.h,v 1.2 2008/12/16 10:20:39 jianguo Exp $
 *
 * LICENSE:
 *     This source code is copyright (c) 2000-2002 RDA Microelectronics Inc.
 *     All rights reserved.
 *
 ***********************************************************************/
#ifndef RDABT_STACK_ENT_API_H
#define RDABT_STACK_ENT_API_H

#include "rfcomm_types.h"

#if RDABT_RFCOMM_RSE_SUPPORT == 1
#define RDABT_STACK_ENT_REFUSE 0
#define RDABT_STACK_ENT_ACCEPT 1

#define RSE_FLOW_STOP 0
#define RSE_FLOW_GO 1

#define RFCOMM_SVR_CHAN_HFP         1
#define RFCOMM_SVR_CHAN_HSP         2
#define RFCOMM_SVR_CHAN_FTP         3
#define RFCOMM_SVR_CHAN_OPP         4

#define RFCOMM_SVR_CHAN_SPP         7
#define RFCOMM_SVR_CHAN_DUN         8

typedef enum {
    RFCOMM_CONNECT_IND = RFCOMM_MSG_BASE,
    RFCOMM_CONNECT_CNF,
    RFCOMM_DATA_IND,
    RFCOMM_FLOW_IND,
    RFCOMM_DISCONNECT_IND,
    RFCOMM_FRAME_SIZE_IND
} RDABT_RFCOMM_RSE_EVENT;


typedef struct st_t_RSE_Msg_Para_t 
{
    rdabt_t_rfcomm_schan schan;
    t_bdaddr address;
    u_int8 status;
    rdabt_t_rfcomm_dlci dlci;
    u_int16 max_frame_size;
    rdabt_host_buf_t *p_buf;
} t_RSE_Msg;


typedef struct st_t_RSE_Callbacks
{
  t_api (*connectionConfirmation)(rdabt_t_rfcomm_schan schan, t_bdaddr address, u_int8 status, rdabt_t_rfcomm_dlci dlci, u_int16 max_frame_size);
  t_api (*connectionIndication)(rdabt_t_rfcomm_schan schan, t_bdaddr address, rdabt_t_rfcomm_dlci dlci, u_int16 max_frame_size);
  t_api (*dataIndication)(t_bdaddr address, rdabt_t_rfcomm_dlci dlci, rdabt_host_buf_t *p_buf);
  t_api (*flowIndication)(t_bdaddr address, rdabt_t_rfcomm_dlci dlci, u_int8 flow_state);  
  t_api (*disconnectionIndication)(t_bdaddr address, rdabt_t_rfcomm_dlci dlci);
  t_api (*framesizeIndication)(t_bdaddr address, rdabt_t_rfcomm_dlci dlci, u_int16 max_frame_size);
} t_RSE_Callbacks;

t_api rdabt_rse_layer_ctrl(u_int8 flags);
APIDECL1 t_api APIDECL2 RSE_SrvRegisterPort(rdabt_t_rfcomm_schan *serv_chan, u_int8 module_id);
APIDECL1 t_api APIDECL2 RSE_SrvDeregisterPort(rdabt_t_rfcomm_schan schan);
APIDECL1 t_api APIDECL2 RSE_SrvDisconnectPort(t_bdaddr remote_bd_addr,rdabt_t_rfcomm_schan schan);
APIDECL1 t_api APIDECL2 RSE_CliConnectPort(t_bdaddr remote_bd_addr, rdabt_t_rfcomm_schan rem_schan, u_int16 max_frame_size, u_int8 module_id);
APIDECL1 t_api APIDECL2 RSE_CliDisconnectPort(t_bdaddr remote_bd_addr, rdabt_t_rfcomm_schan schan);
APIDECL1 t_api APIDECL2 RSE_Write(t_bdaddr remote_bd_addr, rdabt_t_rfcomm_dlci dlci, rdabt_host_buf_t *p_buf);
APIDECL1 t_api APIDECL2 RSE_SrvConnectResponse(t_bdaddr remote_bd_addr, rdabt_t_rfcomm_dlci dlci, u_int8 accept);
APIDECL1 t_api APIDECL2 RSE_GetWriteBuffer(t_bdaddr bdaddr, int dlci, int length, rdabt_host_buf_t **p_buf);
APIDECL1 t_api APIDECL2 RSE_FreeWriteBuffer(rdabt_host_buf_t *frame);
APIDECL1 t_api APIDECL2 RSE_GetCIDFromConnection(t_bdaddr bdaddr, rdabt_t_rfcomm_dlci dlci, u_int16 *cid);

#if RDABT_RFCOMM_RSE_DATA_PUMP_ENABLE 
APIDECL1 t_api APIDECL2 RSE_DataPumpTx(t_bdaddr bdaddr, int dlci, u_int8 pattern_num, u_int16 pkt_size, u_int32 num_packets);
APIDECL1 t_api APIDECL2 RSE_DataPumpTxStop(t_bdaddr bdaddr, int dlci);
APIDECL1 t_api APIDECL2 RSE_DataPumpRxPrepare(t_bdaddr bdaddr, int dlci, u_int32 num_packets_report, void *reserved);
APIDECL1 t_api APIDECL2 RSE_DataPumpRxStop(t_bdaddr bdaddr, int dlci);
APIDECL1 t_api APIDECL2 RSE_DataPumpRxGetStats(t_bdaddr bdaddr, int dlci, u_int32 *total_data, u_int32 *rx_time_diff);

#endif

#endif /* RDABT_RFCOMM_RSE_SUPPORT */

#endif
